package IO流;

import com.sun.xml.internal.ws.addressing.WsaActionUtil;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;

/*
public class Main {
    public static void main(String[] args) throws IOException {
        Path p1 = Paths.get(".", "zhulei", "123"); // 构造一个Path对象
        System.out.println(p1);
        Path p2 = p1.toAbsolutePath(); // 转换为绝对路径
        System.out.println(p2);
        Path p3 = p2.normalize(); // 转换为规范路径
        System.out.println(p3);
        File f = p3.toFile(); // 转换为File对象
        System.out.println(f);
        for (Path p : Paths.get("..").toAbsolutePath()) { // 可以直接遍历Path
            System.out.println(" ==" + p);
        }
    }
}
*/

/*
public class Main {
    public static void main(String[] args) throws  IOException{

        byte[] data;
        try (OutputStream output = new FileOutputStream(".\\study\\src\\IO流\\readme.txt",true)) {

               output.write("Hello".getBytes(StandardCharsets.UTF_8));
               output.close();

        }
        try (InputStream input=new FileInputStream(".\\study\\src\\IO流\\readme.txt"))
        {
            byte[] buffer = new byte[10];
            int n;
            while ((n=input.read(buffer))!=-1)
            {
                String rs = new String(buffer, 0, n);
                System.out.println(rs);
            }
            input.close();
        }
    }
}
*/
/*
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream ins=null;
        OutputStream os=null;

        try {
             ins = new FileInputStream(".\\study\\src\\IO流\\readme.txt");
             os = new FileOutputStream(".\\study\\src\\IO流\\a.txt");
            byte[] buffer = new byte[1024];
            //定义一个变量存储每次桶读取的字节数
            int len;
            while ((len=ins.read(buffer))!=-1)
            {
                os.write(buffer,0,len);
            }
            System.out.println("复制完成！！");
        }catch (Exception e)
        {
            e.printStackTrace();
        }finally {
            if (ins!=null)  ins.close();
            if (os!=null)   os.close();
        }
    }
}
*/




